home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 June / PersonalComputerWorld-June2009-CoverdiscCD.iso / Software / Shareware / Mockups for Desktop 1.5.27 / MockupsForDesktop.air / MockupsAir.swf / scripts / ImportImageFilePanel.as < prev    next >
Encoding:
Text File  |  2009-03-03  |  9.8 KB  |  308 lines

  1. package
  2. {
  3.    import com.plus9.mockups.dialogs.IImportImageDialog;
  4.    import com.plus9.mockups.dialogs.ImportImagePanels.IImportImagePanel;
  5.    import com.plus9.mockups.ui.SketchableLoadingProgressImage;
  6.    import flash.accessibility.*;
  7.    import flash.data.*;
  8.    import flash.debugger.*;
  9.    import flash.desktop.*;
  10.    import flash.display.*;
  11.    import flash.errors.*;
  12.    import flash.events.*;
  13.    import flash.external.*;
  14.    import flash.filesystem.*;
  15.    import flash.filters.*;
  16.    import flash.geom.*;
  17.    import flash.html.*;
  18.    import flash.html.script.*;
  19.    import flash.media.*;
  20.    import flash.net.*;
  21.    import flash.printing.*;
  22.    import flash.profiler.*;
  23.    import flash.system.*;
  24.    import flash.text.*;
  25.    import flash.ui.*;
  26.    import flash.utils.*;
  27.    import flash.xml.*;
  28.    import mx.binding.*;
  29.    import mx.containers.Canvas;
  30.    import mx.controls.Button;
  31.    import mx.controls.Label;
  32.    import mx.core.UIComponentDescriptor;
  33.    import mx.core.mx_internal;
  34.    import mx.events.FlexEvent;
  35.    import mx.events.PropertyChangeEvent;
  36.    import mx.styles.*;
  37.    
  38.    public class ImportImageFilePanel extends Canvas implements IImportImagePanel
  39.    {
  40.       protected var _mainDialog:IImportImageDialog;
  41.       
  42.       private var _2040040073_preview:SketchableLoadingProgressImage;
  43.       
  44.       protected var _file:File;
  45.       
  46.       private var _94482_cv:Canvas;
  47.       
  48.       private var _645204090_fileName:Label;
  49.       
  50.       private var _1327866793_browse:Button;
  51.       
  52.       private var _documentDescriptor_:UIComponentDescriptor;
  53.       
  54.       public function ImportImageFilePanel()
  55.       {
  56.          _documentDescriptor_ = new UIComponentDescriptor({
  57.             "type":Canvas,
  58.             "propertiesFactory":function():Object
  59.             {
  60.                return {
  61.                   "height":384,
  62.                   "width":588,
  63.                   "childDescriptors":[new UIComponentDescriptor({
  64.                      "type":Label,
  65.                      "stylesFactory":function():void
  66.                      {
  67.                         this.textAlign = "right";
  68.                      },
  69.                      "propertiesFactory":function():Object
  70.                      {
  71.                         return {
  72.                            "x":10,
  73.                            "y":7,
  74.                            "text":"Image File:",
  75.                            "width":61
  76.                         };
  77.                      }
  78.                   }),new UIComponentDescriptor({
  79.                      "type":Label,
  80.                      "id":"_fileName",
  81.                      "stylesFactory":function():void
  82.                      {
  83.                         this.left = "82";
  84.                      },
  85.                      "propertiesFactory":function():Object
  86.                      {
  87.                         return {
  88.                            "y":7,
  89.                            "width":421
  90.                         };
  91.                      }
  92.                   }),new UIComponentDescriptor({
  93.                      "type":Canvas,
  94.                      "id":"_cv",
  95.                      "events":{"click":"___cv_click"},
  96.                      "stylesFactory":function():void
  97.                      {
  98.                         this.borderColor = 0;
  99.                         this.left = "80";
  100.                         this.borderStyle = "solid";
  101.                      },
  102.                      "propertiesFactory":function():Object
  103.                      {
  104.                         return {
  105.                            "y":5,
  106.                            "toolTip":"Click to browse",
  107.                            "height":24,
  108.                            "width":425
  109.                         };
  110.                      }
  111.                   }),new UIComponentDescriptor({
  112.                      "type":Button,
  113.                      "id":"_browse",
  114.                      "events":{"click":"___browse_click"},
  115.                      "stylesFactory":function():void
  116.                      {
  117.                         this.right = "10";
  118.                      },
  119.                      "propertiesFactory":function():Object
  120.                      {
  121.                         return {
  122.                            "y":5,
  123.                            "label":"Browse...",
  124.                            "width":70
  125.                         };
  126.                      }
  127.                   }),new UIComponentDescriptor({
  128.                      "type":Label,
  129.                      "propertiesFactory":function():Object
  130.                      {
  131.                         return {
  132.                            "x":28,
  133.                            "y":33,
  134.                            "text":"Preview"
  135.                         };
  136.                      }
  137.                   }),new UIComponentDescriptor({
  138.                      "type":Canvas,
  139.                      "stylesFactory":function():void
  140.                      {
  141.                         this.borderColor = 0;
  142.                         this.backgroundColor = 16315883;
  143.                         this.borderStyle = "solid";
  144.                      },
  145.                      "propertiesFactory":function():Object
  146.                      {
  147.                         return {
  148.                            "x":80,
  149.                            "y":34,
  150.                            "width":498,
  151.                            "height":344
  152.                         };
  153.                      }
  154.                   }),new UIComponentDescriptor({
  155.                      "type":SketchableLoadingProgressImage,
  156.                      "id":"_preview",
  157.                      "propertiesFactory":function():Object
  158.                      {
  159.                         return {
  160.                            "x":82,
  161.                            "y":36,
  162.                            "width":494,
  163.                            "height":340
  164.                         };
  165.                      }
  166.                   })]
  167.                };
  168.             }
  169.          });
  170.          super();
  171.          mx_internal::_document = this;
  172.          this.label = "File";
  173.          this.height = 384;
  174.          this.width = 588;
  175.          this.addEventListener("creationComplete",___ImportImageFilePanel_Canvas1_creationComplete);
  176.       }
  177.       
  178.       [Bindable(event="propertyChange")]
  179.       public function get _fileName() : Label
  180.       {
  181.          return this._645204090_fileName;
  182.       }
  183.       
  184.       public function set mainDialog(param1:IImportImageDialog) : void
  185.       {
  186.          _mainDialog = param1;
  187.          _mainDialog.enableLoad(false);
  188.          if(_browse)
  189.          {
  190.             _browse.setFocus();
  191.          }
  192.       }
  193.       
  194.       public function ___cv_click(param1:MouseEvent) : void
  195.       {
  196.          onClick(param1);
  197.       }
  198.       
  199.       public function ___ImportImageFilePanel_Canvas1_creationComplete(param1:FlexEvent) : void
  200.       {
  201.          onCreationComplete();
  202.       }
  203.       
  204.       override public function initialize() : void
  205.       {
  206.          mx_internal::setDocumentDescriptor(_documentDescriptor_);
  207.          super.initialize();
  208.       }
  209.       
  210.       public function ___browse_click(param1:MouseEvent) : void
  211.       {
  212.          onClick(param1);
  213.       }
  214.       
  215.       public function set _fileName(param1:Label) : void
  216.       {
  217.          var _loc2_:Object = this._645204090_fileName;
  218.          if(_loc2_ !== param1)
  219.          {
  220.             this._645204090_fileName = param1;
  221.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_fileName",_loc2_,param1));
  222.          }
  223.       }
  224.       
  225.       public function set sketched(param1:Boolean) : void
  226.       {
  227.          _preview.sketched = param1;
  228.       }
  229.       
  230.       [Bindable(event="propertyChange")]
  231.       public function get _preview() : SketchableLoadingProgressImage
  232.       {
  233.          return this._2040040073_preview;
  234.       }
  235.       
  236.       public function set _browse(param1:Button) : void
  237.       {
  238.          var _loc2_:Object = this._1327866793_browse;
  239.          if(_loc2_ !== param1)
  240.          {
  241.             this._1327866793_browse = param1;
  242.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_browse",_loc2_,param1));
  243.          }
  244.       }
  245.       
  246.       [Bindable(event="propertyChange")]
  247.       public function get _cv() : Canvas
  248.       {
  249.          return this._94482_cv;
  250.       }
  251.       
  252.       protected function onClick(param1:Event) : void
  253.       {
  254.          switch(param1.target)
  255.          {
  256.             case _browse:
  257.             case _cv:
  258.                _file = new File();
  259.                _file.browseForOpen("Please select the image to embed",[new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)","*.jpg;*.jpeg;*.gif;*.png")]);
  260.                _file.addEventListener(Event.SELECT,onSelect);
  261.          }
  262.       }
  263.       
  264.       public function set _cv(param1:Canvas) : void
  265.       {
  266.          var _loc2_:Object = this._94482_cv;
  267.          if(_loc2_ !== param1)
  268.          {
  269.             this._94482_cv = param1;
  270.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_cv",_loc2_,param1));
  271.          }
  272.       }
  273.       
  274.       [Bindable(event="propertyChange")]
  275.       public function get _browse() : Button
  276.       {
  277.          return this._1327866793_browse;
  278.       }
  279.       
  280.       public function set _preview(param1:SketchableLoadingProgressImage) : void
  281.       {
  282.          var _loc2_:Object = this._2040040073_preview;
  283.          if(_loc2_ !== param1)
  284.          {
  285.             this._2040040073_preview = param1;
  286.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_preview",_loc2_,param1));
  287.          }
  288.       }
  289.       
  290.       protected function onCreationComplete() : void
  291.       {
  292.          if(visible)
  293.          {
  294.             _browse.setFocus();
  295.          }
  296.       }
  297.       
  298.       protected function onSelect(param1:Event) : void
  299.       {
  300.          _mainDialog.enableLoad(true);
  301.          _fileName.text = _file.url;
  302.          _preview.source = _file.url;
  303.          _mainDialog.selectedURL = _file.url;
  304.       }
  305.    }
  306. }
  307.  
  308.